package edu.washington.ling.syntric.io;

import edu.washington.ling.syntric.struct.error.InvalidValueException;
import edu.washington.ling.syntric.struct.error.UnreadableRepresentationException;
import edu.washington.ling.syntric.struct.tree.Tree;
public abstract class TreeReader {
	public static TreeReader newReader(String format) throws InvalidValueException {
		TreeReader tr;
		if (format.equals("ssf"))
			tr = new TreeReaderSSF();
		else if (format.equals("ptb"))
			tr = new TreeReaderPTB();
		else if (format.equals("links"))
			tr = new TreeReaderLinks();
		else {
			String[] possibleFormats = {"ssf", "ptb", "links"};
			throw new InvalidValueException("Specified tree format unknown.", format, possibleFormats);
		}
		return tr;
	}
	public abstract String getFormat();
	public abstract void checkRepFormat(TreeRepresentation rep) throws UnreadableRepresentationException;
	public abstract Tree readTree(TreeRepresentation rep) throws UnreadableRepresentationException;
}
